import random
from datetime import datetime

import clickhouse_connect

connect_info = {
    'port': 8123,
    'host': '192.168.103.43',
    'username': 'admin',
    'password': '@Abcd1234',
    'database': 'nirvana_ahyd'
}
client = clickhouse_connect.get_client(**connect_info)
sql = "select zy_resource_code from dim_id_basic_data_res"
result00 = client.query(sql)
fields = result00.result_rows
with open('E:test3.txt', 'w', encoding='utf-8') as f:
    f.write('zy_resource_code')
    for field in fields:
        f.write('\n%s' % (field[0]))
    f.write('\n')
f.close()
client.close()
